/****************************************************************
 *  * *Process the diff os interface test
 *  * *
 *  * *file name:mct_os_test.cpp
 *  * *
 *  * *Copyright (C)2012 Cisco webex.
 *  * *All rights reserved
 *  * *
 *  * *Author:zhenye
 *  * *Date  :2013-03-06
 *  * *
 *  * ****************************************************************/
#include <string>
#include "mct_system.h"
#include "mct_resmgr.h"
#include "logfile.h"
#include "logmgr.h"

 int main(int argc, char **argv)
{
   /* test the memory alloc and guard */
   CHAR *test = NULL;
   {
        test = (CHAR *) MCT_malloc(10, 0);
        CMCTMemoryGuard oTemp(test);
        printf("test address 0x%x \r\n", test);
    }
    printf("test address 0x%x \r\n", test);

    /* test the function  MCT_system */
#ifdef WIN32
    MCT_system("dir");
#else
    MCT_system("ls -lt /home");
#endif

    /* test write log */
    std::string strLogCfg="./conf/testlog.cfg";
    CLogger *poInstance = CLogger::getInstance(strLogCfg);
    poInstance->setPriority(LOG_WARN);
    DumpMsg0(LOG_ERROR, "error test!");
    DumpMsg0(LOG_WARN, "warning test!");
    DumpMsg0(LOG_INFO, "info test!");

    MCT_STRACE(LOG_WARN, "SHORT:"<<(SHORT)-1<<"=="<<CTextStream::mct_hex<<(SHORT)-1);
    MCT_STRACE(LOG_WARN, "USHORT:"<<(USHORT)123<<"=="<<CTextStream::mct_hex<<(USHORT)123);
    MCT_STRACE(LOG_WARN, "INT:"<<(int)-1<<"=="<<CTextStream::mct_hex<<(int)-1);
    MCT_STRACE(LOG_WARN, "UINT:"<<(unsigned int)123<<"=="<<CTextStream::mct_hex<<(unsigned int)123);
    MCT_STRACE(LOG_WARN, "LONG:"<<(LONG)-1<<"=="<<CTextStream::mct_hex<<(LONG)-1);
    MCT_STRACE(LOG_WARN, "ULONG:"<<(ULONG)123<<"=="<<CTextStream::mct_hex<<(ULONG)123);
    MCT_STRACE(LOG_WARN, "FLOAT:"<<(FLOAT)-1.1<<"=="<<CTextStream::mct_hex<<(FLOAT)-1.1);
    MCT_STRACE(LOG_WARN, "DOUBLE:"<<(DOUBLE)123.1<<"=="<<CTextStream::mct_hex<<(DOUBLE)123.1);
    MCT_STRACE(LOG_WARN, "DLONG:"<<(DLONG)-1<<"=="<<CTextStream::mct_hex<<(DLONG)-1);
    MCT_STRACE(LOG_WARN, "DULONG:"<<(DULONG)123<<"=="<<CTextStream::mct_hex<<(DULONG)123);

    return 0;
}

